package com.dime.basic.controller;

import com.dime.basic.api.model.*;
import com.dime.basic.service.IOccupationalBasicService;
import com.dime.basic.service.impl.OccupationalBasicService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.annotation.InnerAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/occupationalbasic")
public class OccupationalBasicController {

    @Autowired
    private IOccupationalBasicService service;
    @InnerAuth
    @GetMapping("getoccupationalbasic")
    public R<OccupationalBasic> occupationalBasic()
    {

       OccupationalBasic occupationalBasic= service.getOccupationalBasic();
        return R.ok(occupationalBasic);
    }
    @InnerAuth
    @PostMapping("/info/getHarmDiseaseCriterions")
    public R<HarmDiseaseCriterion> harmDiseaseCriterions(@RequestBody HarmWorkStatus hws)
    {
        HarmDiseaseCriterion diseaseCriterions= service.getHarmDiseaseCriterions(hws);
        return R.ok(diseaseCriterions);
    }
    @InnerAuth
    @PostMapping("/info/getHarmContraCriterions")
    public R<HarmDiseaseCriterion> harmContraCriterions(@RequestBody HarmWorkStatus hws){
        HarmDiseaseCriterion diseaseCriterions= service.getHarmDiseaseCriterions(hws);
        return R.ok(diseaseCriterions);
    }
    @InnerAuth
    @PostMapping("/info/harmDiseaseCriterionsByList")
    public R<List<HarmDiseaseCriterion>> harmDiseaseCriterionsByList(@RequestBody ArrayList<HarmWorkStatus> hws)
    {
        try {
        List<HarmDiseaseCriterion> diseaseCriterions= service.getHarmDiseaseCriterionsByList(hws);
        return R.ok(diseaseCriterions);
        }catch (Exception ex) {
            return R.fail(ex.getMessage());
        }
    }
    @InnerAuth
    @PostMapping("/info/harmContraCriterionsByList")
    public R<List<HarmContraCriterion>> harmContraCriterionsByList(@RequestBody ArrayList<HarmWorkStatus> hws){
        try {
            List<HarmContraCriterion> contraCriterions = service.getHarmContraCriterionsByList(hws);
            return R.ok(contraCriterions);
        }catch (Exception ex) {
            return R.fail(ex.getMessage());
        }

    }
}
